import {createRouter, createWebHistory, type RouteRecordRaw} from 'vue-router'
import type {ResMenuList} from '@/api/interface'

export const staticRoutes: RouteRecordRaw[] = [
	{
		path: '/login',
		name: 'login',
		component: async () => await import('@/views/login/index.vue'),
		meta: {title: '登录', icon: '', noCache: true, link: null}
	},
	{
		path: '/403',
		name: '403',
		component: async () => await import('@/views/error/403.vue'),
		meta: {title: '403', icon: '', noCache: true, link: null}
	},
	{
		path: '/404',
		name: '404',
		component: async () => await import('@/views/error/404.vue'),
		meta: {title: '404', icon: '', noCache: true, link: null}
	},
	{
		path: '/500',
		name: '500',
		component: async () => await import('@/views/error/500.vue'),
		meta: {title: '500', icon: '', noCache: true, link: null}
	}
]

export const addStaticRoutes: ResMenuList[] = [
	{
		name: 'example',
		path: 'example',
		hidden: false,
		component: 'Layout',
		meta: {title: 'test', icon: 'Operation', noCache: true, link: null},
		redirect: 'index',
		children: [
			{
				name: 'exampleIndex',
				path: 'index',
				hidden: false,
				component: 'example/index',
				meta: {title: '测试', icon: 'Operation', noCache: true, link: null}
			}
		]
	}
]

const router = createRouter({
	routes: [...staticRoutes],
	history: createWebHistory(),
	strict: false,
	scrollBehavior: () => ({left: 0, top: 0})
})

export default router
